﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Renci.iRods.Common;

namespace Renci.iRods.Data
{
    public class ServerDigest : DataItem
    {
        [iRodsColumn(DataObjectAttributes.COL_SLD_RESC_NAME)]
        public string ResourceName { get; internal set; }

        [iRodsColumn(DataObjectAttributes.COL_SLD_LOAD_FACTOR)]
        public int LoadFactor { get; internal set; }

        [iRodsColumn(DataObjectAttributes.COL_SLD_CREATE_TIME)]
        public DateTime CreatedTime { get; internal set; }

        internal ServerDigest(IRodsConnection connection)
            : base(connection)
        {

        }

        public ServerDigest(IRodsConnection connection, string resourceName)
            : base(connection)
        {
            this.ResourceName = resourceName;
        }

        public override void Refresh()
        {
            this.Exists = this.Load((q) =>
            {
                q.AddCondition(DataObjectAttributes.COL_SLD_RESC_NAME, string.Format("='{0}'", this.ResourceName));
            });
        }
    }
}
